<template>
  <div class="hrRegisterContainer">
    <div class="input-container">
      <el-tabs
        class="tab-container"
        v-model="activeName"
        type="border-card"
        @tab-click="handleClick"
      >
        <el-tab-pane label="个人信息" name="first">
          <el-form
            :model="personalInformationFormData"
            ref="personalInformationForm"
            label-width="100px"
            class="personalInformationFormData"
          >
            <el-form-item label="头像" prop="avatar">
              <el-upload
                class="avatar-uploader"
                action="https://jsonplaceholder.typicode.com/posts/"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <img
                  v-if="personalInformationFormData.avatar"
                  :src="personalInformationFormData.avatar"
                  class="avatar"
                  style="max-width: 100px; max-height: 100px"
                />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
            <!-- <el-form-item label="用户名" prop="username">
              <el-input
                v-model="personalInformationFormData.username"
                placeholder="请输入用户名"
              ></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
              <el-input
                v-model="personalInformationFormData.password"
                placeholder="请输入密码"
                show-password
              ></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="resetPassword">
              <el-input
                v-model="personalInformationFormData.resetPassword"
                placeholder="确认密码"
                show-password
              ></el-input>
            </el-form-item> -->
            <el-form-item label="真实姓名" prop="name">
              <el-input
                v-model="personalInformationFormData.name"
                placeholder="请输入姓名"
              ></el-input>
            </el-form-item>
            <!-- <el-form-item label="邮箱" prop="email">
              <div class="email">
                <el-input
                  v-model="personalInformationFormData.email"
                  placeholder="请输入邮箱"
                  style="width: 280px;"
                ></el-input>
                <el-button style="margin-left: 10px;width:160px" type="primary" @click="getVerificationCode">获取邮箱验证码</el-button>
              </div>
            </el-form-item>
            <el-form-item label="验证码" prop="code">
              <el-input
                v-model="personalInformationFormData.captcha"
                placeholder="请输入邮箱验证码"
              ></el-input>
            </el-form-item> -->
            <el-form-item label="电话" prop="phone">
              <el-input
                v-model="personalInformationFormData.phone"
                placeholder="请电话号码"
              ></el-input>
            </el-form-item>
            <el-button
              style="margin-left: 84%"
              class="submit-button"
              type="primary"
              @click="submit"
            >
              提交更新
            </el-button>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="绑定或修改邮箱" name="fifth">
          <el-form-item label="邮箱" prop="email" style="margin-top: 30px">
            <div class="email">
              <el-input
                v-model="personalInformationFormData.email"
                placeholder="请输入邮箱"
                style="width: 280px"
              ></el-input>
              <el-button
                style="margin-left: 10px; width: 160px"
                type="primary"
                @click="getVerificationCode"
              >
                获取邮箱验证码
              </el-button>
            </div>
          </el-form-item>
          <el-form-item label="验证码" prop="captcha">
            <el-input
              v-model="personalInformationFormData.captcha"
              placeholder="请输入邮箱验证码"
              style="width: 432px"
            ></el-input>
          </el-form-item>
          <el-form-item label="旧邮箱" prop="oldEmail">
            <el-input
              v-if="userStore.userInfo.email != null"
              v-model="personalInformationFormData.oldEmail"
              placeholder="请输入旧邮箱"
              style="width: 430px"
            ></el-input>
          </el-form-item>
          <div>
            <el-button
              v-if="userStore.userInfo.email === null"
              style="margin-left: 72%"
              type="primary"
              @click="bondEmail"
            >
              绑定邮箱
            </el-button>
            <el-button
              v-else
              style="margin-left: 72%"
              type="primary"
              @click="changeEmail"
            >
              修改邮箱
            </el-button>
          </div>
        </el-tab-pane>
        <el-tab-pane label="HR信息" name="second">
          <el-form
            :model="hrInformationFormData"
            ref="hrInformationForm"
            label-width="100px"
            class="hrInformationFormata"
          >
            <el-row>
              <el-col :span="10">
                <!-- <el-tooltip
                  class="input-companyId"
                  effect="dark"
                  content="如果没有公司请填写后续的公司信息和公司工商信息"
                  placement="top"
                > -->
                <el-form-item class="input-companyId" label="公司ID">
                  <el-input
                    :disabled="true"
                    placeholder="填写公司id"
                    v-model="hrInformationFormData.companyId"
                  ></el-input>
                </el-form-item>
                <!-- </el-tooltip> -->
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <!-- <el-form-item label="用户ID">
                  <el-input placeholder="请填写用户id" v-model="hrInformationFormData.userId"></el-input>
                </el-form-item> -->
                <el-form-item label="性别">
                  <el-radio-group v-model="hrInformationFormData.gender">
                    <el-radio :label="0">男</el-radio>
                    <el-radio :label="1">女</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <!-- <el-form-item label="姓名">
                  <el-input placeholder="请填写真实姓名" v-model="hrInformationFormData.realname"></el-input>
                </el-form-item> -->
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <!-- <el-form-item label="性别">
                  <el-radio-group v-model="hrInformationFormData.gender">
                    <el-radio :label="0">男</el-radio>
                    <el-radio :label="1">女</el-radio>
                  </el-radio-group>
                </el-form-item> -->
              </el-col>
            </el-row>
            <!-- <el-row>
              <el-col :span="10">
                <el-form-item label="邮箱">
                  <el-input placeholder="请填写邮箱" v-model="hrInformationFormData.email"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="电话">
                  <el-input placeholder="请填写电话号码" v-model="hrInformationFormData.phone"></el-input>
                </el-form-item>
              </el-col>
            </el-row> -->
            <el-row>
              <el-col :span="10">
                <el-form-item label="出生日期">
                  <el-date-picker
                    type="date"
                    v-model="hrInformationFormData.birthdate"
                    placeholder="选择日期"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="入职时间">
                  <el-date-picker
                    type="date"
                    v-model="hrInformationFormData.onboardingTime"
                    placeholder="选择日期"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="职位">
              <el-input
                placeholder="请填写公司职位"
                style="width: 90%"
                v-model="hrInformationFormData.job"
              ></el-input>
            </el-form-item>
          </el-form>
          <el-button
            style="margin-left: 76%"
            type="primary"
            @click="updateHrInformation"
          >
            提交hr信息
          </el-button>
        </el-tab-pane>
        <el-tab-pane label="公司信息" name="third">
          <el-form
            :model="companyInformationFormData"
            ref="companyInformationForm"
            label-position="top"
          >
            <el-form-item label="" prop="logo">
              <el-upload
                class="avatar-uploader"
                action="https://jsonplaceholder.typicode.com/posts/"
                :show-file-list="false"
                :on-success="handleLogoSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <img
                  v-if="companyInformationFormData.logo"
                  :src="companyInformationFormData.logo"
                  style="max-width: 100px; max-height: 100px"
                />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
            <el-row>
              <el-col :span="10">
                <el-form-item label="公司行业" prop="industryId">
                  <el-cascader
                    v-model="companyInformationFormData.industryId"
                    :options="options"
                    :props="props"
                    @change="handleChange"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="公司全称" prop="name">
                  <el-input
                    v-model="companyInformationFormData.name"
                    placeholder="公司全称"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="融资阶段" prop="financingStage">
                  <el-select
                    v-model="companyInformationFormData.financingStage"
                    placeholder="请选择融资阶段"
                  >
                    <el-option label="未融资" :value="1"></el-option>
                    <el-option label="天使轮" :value="2"></el-option>
                    <el-option label="A轮" :value="3"></el-option>
                    <el-option label="B轮" :value="4"></el-option>
                    <el-option label="C轮" :value="5"></el-option>
                    <el-option label="D轮及以上" :value="6"></el-option>
                    <el-option label="已上市" :value="7"></el-option>
                    <el-option label="不需要融资" :value="8"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="公司规模" prop="scala">
                  <el-select
                    v-model="companyInformationFormData.scala"
                    placeholder="请选择公司规模"
                  >
                    <el-option label="0~20人" :value="1"></el-option>
                    <el-option label="20~99人" :value="2"></el-option>
                    <el-option label="100~499人" :value="3"></el-option>
                    <el-option label="500~999人" :value="4"></el-option>
                    <el-option label="1000~9999人" :value="5"></el-option>
                    <el-option label="10000人以上" :value="6"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="其他自定义标签" prop="otherTag">
                  <div class="flex gap-2">
                    <el-tag
                      v-for="tag in dynamicTags"
                      :key="tag"
                      closable
                      style="margin-left: 3px"
                      :disable-transitions="false"
                      @close="handleClose(tag)"
                    >
                      {{ tag }}
                    </el-tag>
                    <el-input
                      v-if="inputVisible"
                      ref="InputRef"
                      v-model="inputValue"
                      class="w-20"
                      size="small"
                      @keyup.enter="handleInputConfirm"
                      @blur="handleInputConfirm"
                    />
                    <el-button
                      style="margin-left: 3px"
                      v-else
                      class="button-new-tag"
                      size="small"
                      @click="showInput"
                    >
                      + New Tag
                    </el-button>
                  </div>
                  <!-- <el-input
                    v-model="companyInformationFormData.otherTag"
                    placeholder="输入其他自定义标签"
                  ></el-input> -->
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="公司地点" prop="location">
                  <el-input
                    v-model="companyInformationFormData.location"
                    placeholder="公司地点"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="公司简介" prop="introduction">
              <v-md-editor
                v-model="companyInformationFormData.introduction"
                mode="edit"
              ></v-md-editor>
              <!-- <el-input v-model="companyInformationFormData.introduction" type="textarea" placeholder="公司简介"></el-input> -->
            </el-form-item>
            <el-form-item>
              <el-button
                style="margin-left: 480px"
                type="primary"
                @click="submitCompanyForm"
              >
                提交更新
              </el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="工商信息表" name="fourth">
          <el-form
            :model="businessFormData"
            ref="businessForm"
            label-position="top"
          >
            <el-row>
              <el-col :span="10">
                <!-- <el-form-item label="公司ID" prop="companyId">
                  <el-input
                    v-model="businessFormData.companyId"
                    placeholder="公司ID"
                  ></el-input>
                </el-form-item> -->
                <el-form-item label="经营状态" prop="status">
                  <el-select
                    v-model="businessFormData.status"
                    placeholder="请选择经营状态"
                  >
                    <el-option label="存续" :value="1"></el-option>
                    <el-option label="在业" :value="2"></el-option>
                    <el-option label="吊销" :value="3"></el-option>
                    <el-option label="注销" :value="4"></el-option>
                    <el-option label="迁入" :value="5"></el-option>
                    <el-option label="迁出" :value="6"></el-option>
                    <el-option label="停业" :value="7"></el-option>
                    <el-option label="清算" :value="8"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="公司全称" prop="name">
                  <el-input
                    v-model="businessFormData.name"
                    placeholder="公司全称"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="成立时间" prop="establishmentTime">
                  <el-date-picker
                    type="date"
                    placeholder="选择日期"
                    v-model="businessFormData.establishmentTime"
                    style="width: 100%"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="注册资金" prop="registeredCapital">
                  <el-input-number
                    :min="0"
                    v-model="businessFormData.registeredCapital"
                    placeholder="注册资金"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="法人代表" prop="legalRepresentative">
                  <el-input
                    v-model="businessFormData.legalRepresentative"
                    placeholder="法人代表"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="注册地址" prop="registeredLocation">
                  <el-input
                    v-model="businessFormData.registeredLocation"
                    placeholder="注册地址"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="统一信用代码" prop="code">
                  <el-input
                    v-model="businessFormData.code"
                    placeholder="统一信用代码"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="所属行业" prop="industry">
                  <el-input
                    v-model="businessFormData.industry"
                    placeholder="所属行业"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10">
                <el-form-item label="所在地" prop="location">
                  <el-input
                    v-model="businessFormData.location"
                    placeholder="所在地"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="登记机关" prop="registrationAuthority">
                  <el-input
                    v-model="businessFormData.registrationAuthority"
                    placeholder="登记机关"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="10">
                <el-form-item label="营业期限" prop="businessTerm">
                  <el-input
                    v-model="businessFormData.businessTerm"
                    placeholder="营业期限"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2"></el-col>
              <el-col :span="10">
                <el-form-item label="企业类型" prop="type">
                  <el-input
                    v-model="businessFormData.type"
                    placeholder="企业类型"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-form-item label="经营状态" prop="status">
              <el-select
                v-model="businessFormData.status"
                placeholder="请选择经营状态"
              >
                <el-option label="存续" :value="1"></el-option>
                <el-option label="在业" :value="2"></el-option>
                <el-option label="吊销" :value="3"></el-option>
                <el-option label="注销" :value="4"></el-option>
                <el-option label="迁入" :value="5"></el-option>
                <el-option label="迁出" :value="6"></el-option>
                <el-option label="停业" :value="7"></el-option>
                <el-option label="清算" :value="8"></el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="经营范围" prop="scope">
              <el-input
                v-model="businessFormData.scope"
                type="textarea"
                placeholder="经营范围"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                style="margin-left: 480px"
                @click="submitBusinessForm"
              >
                提交更新
              </el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, nextTick } from 'vue'
import { useUserStoreHook } from '@/store/modules/user'
import { ElMessage, ElInput } from 'element-plus'
import {
  getCompanyInfoById,
  getHrOneById,
  getHrMe,
  putCompanyOne,
  putCompanyBusiness,
  postUserOne,
  getUserOne,
  getEmailCaptchaBindingEmailByEmail,
  postUserEmail,
  putUserEmail,
  putUserPhone,
  postUserHr,
  putHrOne,
  postCompanyOne,
  postCompanyBusiness,
} from '@/servers/controller'
import { SET_TOKEN, GET_TOKEN, REMOVE_TOKEN } from '@/utils/token'

const userStore = useUserStoreHook()
const activeName = ref('first')

let personalInformationForm = ref()
const personalInformationFormData = reactive({
  username: '',
  password: '',
  resetPassword: '',
  avatar:
    'https://guet-lab.oss-cn-hangzhou.aliyuncs.com/api/2024/03/26/341923d8-a69c-4c11-940a-22e9f1d8791b.png',
  email: '',
  oldEmail: '',
  phone: '',
  name: '',
  captcha: '',
})

let hrInformationForm = ref()
const hrInformationFormData = ref({
  id: null,
  companyId: null,
  userId: 0,
  realname: '',
  gender: 1,
  job: '',
  email: '',
  phone: '',
  birthdate: '',
  onboardingTime: '',
})

let companyInformationForm = ref()
const companyInformationFormData = ref({
  logo: 'https://guet-lab.oss-cn-hangzhou.aliyuncs.com/api/2024/03/26/341923d8-a69c-4c11-940a-22e9f1d8791b.png',
  name: '',
  introduction: '',
  financingStage: 1,
  scala: 1,
  industryId: 0,
  otherTag: [],
  location: '',
})

let businessForm = ref()
const businessFormData = ref({
  companyId: 0,
  name: '',
  establishmentTime: '',
  registeredCapital: 10000,
  legalRepresentative: '',
  registeredLocation: '',
  code: '',
  industry: '',
  location: '',
  registrationAuthority: '',
  businessTerm: '',
  type: '',
  status: 2,
  scope: '',
})

const handleAvatarSuccess = (res: any, file: any) => {
  personalInformationFormData.avatar = URL.createObjectURL(file.raw)
}

const handleLogoSuccess = (res: any, file: any) => {
  companyInformationFormData.value.logo = URL.createObjectURL(file.raw)
}

const beforeAvatarUpload = (file: any) => {
  const isJPG = file.type === 'image/jpeg'
  const isLt2M = file.size / 1024 / 1024 < 2

  if (!isJPG) {
    ElMessage.error('上传头像图片只能是 JPG 格式!')
  }
  if (!isLt2M) {
    ElMessage.error('上传头像图片大小不能超过 2MB!')
  }
  return isJPG && isLt2M
}

//tags//////////////////////////////////

const inputValue = ref('')
const dynamicTags = ref([])
const inputVisible = ref(false)
const InputRef = ref<InstanceType<typeof ElInput>>()

const handleClose = (tag: string) => {
  //@ts-ignore
  dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1)
}

const showInput = () => {
  inputVisible.value = true
  nextTick(() => {
    InputRef.value!.input!.focus()
  })
}

const handleInputConfirm = () => {
  if (inputValue.value) {
    //@ts-ignore
    dynamicTags.value.push(inputValue.value)
  }
  inputVisible.value = false
  inputValue.value = ''
}
///////////////////////////////////////////

//获取标签//////////////////////////////
const options = ref([])
const value = ref([])

const props = {
  expandTrigger: 'hover' as const,
  value: 'id',
  label: 'name',
  checkStrictly: true, //只显示最后一个
}

const getAllTag = async () => {
  let storageTag = sessionStorage.getItem('allTag')
  if (storageTag != null) {
    options.value = JSON.parse(storageTag)
    console.log('options:', options.value)
    return
  }
  try {
    //@ts-ignore
    const { data } = await getAllTag()
    sessionStorage.setItem('allTag', JSON.stringify(data.data))
    options.value = data.data
  } catch (e) {
    ElMessage.error((e as Error).message)
  }
  console.log('options:', options.value)
}

const handleChange = (value: any) => {
  console.log(value)
}
//////////////////////////////////////////

const submitBusinessForm = async () => {
  // @ts-ignore
  const res = await putCompanyBusiness(businessFormData.value)
  if (res.data.code === 200) {
    ElMessage.success('更新成功')
  } else {
    ElMessage.error('更新失败')
  }
}

const submitCompanyForm = async () => {
  // if (Array.isArray(dynamicTags.value) && dynamicTags.value.length > 0) {
  //   const firstData = dynamicTags.value[0];
  //   companyInformationFormData.value.otherTag = firstData
  // }
  companyInformationFormData.value.otherTag = dynamicTags.value
  // @ts-ignore
  const industryList: [] = companyInformationFormData.value.industryId
  const industryNumber = industryList[industryList.length - 1]
  companyInformationFormData.value.industryId = industryNumber
  // @ts-ignore
  const res = await putCompanyOne(companyInformationFormData.value)
  if (res.data.code === 200) {
    ElMessage.success('更新成功')
  } else {
    ElMessage.error('更新失败')
  }
}

//修改个人信息
const updatePersonalInformation = async () => {
  const personalInformation = ref({
    avatar: personalInformationFormData.avatar,
    name: personalInformationFormData.name,
    phone: personalInformationFormData.phone,
  })
  const res = await postUserOne(personalInformation.value)
  if (res.data.code === 200) {
    console.log('修改用户信息成功')
  } else {
    ElMessage.error('修改用户信息失败')
  }
}

//修改hr信息
const updateHrInformation = async () => {
  await userStore.getUserInfo()
  //@ts-ignore
  const hrInfor = {
    id: hrInformationFormData.value.id,
    companyId: hrInformationFormData.value.companyId,
    userId: userStore.userInfo.id,
    realname: userStore.userInfo.name,
    gender: hrInformationFormData.value.gender,
    job: hrInformationFormData.value.job,
    email: userStore.userInfo.email,
    phone: userStore.userInfo.phone,
    birthdate: hrInformationFormData.value.birthdate,
    onboardingTime: hrInformationFormData.value.onboardingTime,
  }
  console.log('hrID:', hrInformationFormData.value.id)
  console.log('birthdate:', hrInformationFormData.value.birthdate)
  console.log('onboardingTime:', hrInformationFormData.value.onboardingTime)
  console.log('hrinfo:', hrInfor)
  //@ts-ignore
  const res = await putHrOne(hrInfor)
  if (res.data.code === 200) {
    console.log('修改hr信息成功')
  } else {
    ElMessage.error('修改hr信息失败')
  }
}

//获取邮箱验证码
const getVerificationCode = async () => {
  const res = await getEmailCaptchaBindingEmailByEmail({
    email: personalInformationFormData.email,
  })
  if (res.data.code === 200) {
    console.log('获取邮箱验证码成功')
  } else {
    ElMessage.error('获取邮箱验证码失败')
  }
}

//绑定邮箱
const bondEmail = async () => {
  const res = await postUserEmail({
    email: personalInformationFormData.email,
    captcha: personalInformationFormData.captcha,
  })
  if (res.data.code === 200) {
    console.log('绑定邮箱成功')
  } else {
    ElMessage.error('绑定邮箱失败')
  }
}

//修改邮箱
const changeEmail = async () => {
  const res = await putUserEmail({
    oldEmail: personalInformationFormData.oldEmail,
    email: personalInformationFormData.email,
    captcha: personalInformationFormData.captcha,
  })
  if (res.data.code === 200) {
    console.log('修改邮箱成功')
  } else {
    ElMessage.error('修改邮箱失败')
  }
}

//绑定电话号码
const bondPhoneNumber = async () => {
  const res = await putUserPhone({
    phone: personalInformationFormData.phone,
  })
  if (res.data.code === 200) {
    console.log('绑定电话成功')
  } else {
    ElMessage.error('绑定电话失败')
  }
}

const submit = async () => {
  await updatePersonalInformation()
  await bondPhoneNumber()
  console.log('更新个人信息')
}

const handleClick = () => {
  console.log('tab click')
}

const loadData = async () => {
  await userStore.getUserInfo()
  await getAllTag()
  if (userStore.userInfo.id !== undefined) {
    // @ts-ignore
    personalInformationFormData.name = userStore.userInfo.name
    // @ts-ignore
    personalInformationFormData.phone = userStore.userInfo.phone
    // @ts-ignore
    personalInformationFormData.avatar = userStore.userInfo.avatar
    // const res = await getHrOneById({
    //   id: userStore.userInfo.id,
    // })
    const res = await getHrMe()
    if (res.data.code === 200) {
      //获取hr信息
      // @ts-ignore
      hrInformationFormData.value = { ...res.data.data }
      // @ts-ignore
      hrInformationFormData.value.companyId = res.data.data.companyInfoVo.id
      console.log('hrInfo:', hrInformationFormData.value)
      //获取公司信息
      // @ts-ignore
      companyInformationFormData.value = { ...res.data.data.companyInfoVo }
      const companyId = res.data.data.companyInfoVo.id
      // @ts-ignore
      companyInformationFormData.value.cid = companyId
      // @ts-ignore
      dynamicTags.value = companyInformationFormData.value.otherTag
      //获取工商信息
      const res1 = await getCompanyInfoById({ id: companyId })
      if (res1.data.code === 200) {
        // @ts-ignore
        businessFormData.value = { ...res1.data.data.businessInformationVo }
        // @ts-ignore
        businessFormData.value.companyId = companyId
      } else {
        ElMessage.error('获取失败:' + res1.data.message)
      }
    } else {
      ElMessage.error('获取失败:' + res.data.message)
    }
  }
}

onMounted(() => {
  loadData()
})
</script>

<style lang="scss" scoped>
.input-container {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.tab-container {
  min-width: 600px;
  min-height: 300px;
}

.hrRegisterContainer {
  overflow: auto;
  max-height: 700px; /* 设置最大高度，超出时将显示滚动条 */
}

.email {
  display: flex;
}
</style>
